﻿<Page
    x:Class="TestingApp.Pages.Admin.TestEditorPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:TestingApp.Pages.Admin"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="TestEditorPage"
    d:DesignHeight="450"
    d:DesignWidth="800"
    DataContext="{Binding Source={StaticResource VmLocator}, Path=TestEditorPageViewModel}"
    mc:Ignorable="d">

    <!--  02ч 05м  -->
    <Grid>
        <StackPanel
            MinWidth="500"
            HorizontalAlignment="Center"
            VerticalAlignment="Center">

            <TextBlock Text="Название контрольной работы" />
            <TextBox Text="{Binding Test.Title}" />

            <TextBlock Text="Количество вопросов в тесте" />
            <TextBox Text="{Binding Test.QuestionCount}" TextAlignment="Center" />

            <ItemsControl ItemsSource="{Binding Test.Questions}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border
                            Margin="0,5"
                            Padding="5"
                            BorderBrush="Black"
                            BorderThickness="1"
                            CornerRadius="5">
                            <StackPanel>
                                <TextBox Margin="5" Text="{Binding Text}" />
                                <ItemsControl ItemsSource="{Binding Answers}">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="auto" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <RadioButton
                                                    Grid.Column="0"
                                                    Margin="5"
                                                    VerticalAlignment="Center"
                                                    VerticalContentAlignment="Center"
                                                    GroupName="{Binding RelativeSource={RelativeSource AncestorType=Border}, Path=DataContext.Text}"
                                                    IsChecked="{Binding IsCorrect}" />
                                                <TextBox
                                                    Grid.Column="1"
                                                    Margin="5"
                                                    Text="{Binding Text}" />
                                            </Grid>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <Button
                Margin="0,50,0,0"
                Command="{Binding Save}"
                Content="Сохранить" />
        </StackPanel>
    </Grid>
</Page>
